$(function () {
    console.info("start user");

    let token = $("meta[name='_csrf']").attr("content");
    let header = $("meta[name='_csrf_header']").attr("content");
    $(document).ajaxSend(function (e, xhr, options) {
        xhr.setRequestHeader(header, token);
    });

    /*$('#dataTable').bootstrapTable("refreshOptions", {
        columns: [{
            title: '行号',
            align: 'center',
            valign: 'bottom',
            formatter: function (value, row, index) {
                return index + 1;
            }
        }]
    });*/

    initSelect();
});

function initSelect() {
    $.post("/role/findRoleList", {}, function (data) {
        let html = '';
        for (let i = 0; i < data.length; i++) {
            html += '<option value="' + data[i].name + '">' + data[i].desc + '</option>';
        }
        $('#roleSelect').append(html);
        if (data.length > 0)
            $('#roleSelect').find("option[value='" + data[0].name + "']").attr("selected", true);
    });
}

function doCreate(obj) {
    $('#userModal').modal('show');
}

function doEdit(obj) {
    $('#userModal').modal('show');
}

function doDelete(obj) {

}

function doSave(obj) {

}